/**
 * huize Service Inc
 * All Rights Reserved @2018
 */
package com.huize.zhike.framework.common.enumeration;

import com.huize.ladon.apm.common.enums.EnumInterface;
import com.huize.ladon.apm.common.util.MixAllUtils;

/**
 * 描述: 是否拥有租户权限
 *
 * @author tianyuliang
 * @version $Id: HasTenantEnum.java, v0.1 2020/9/1
 */
public enum HasTenantEnum implements EnumInterface {

    /**
     * 有（具有租户权限）
     */
    HAS(true, "有"),


    /**
     * 没有（不具有租户权限）
     */
    NONE(false, "没有"),

    ;

    private Boolean type;

    private String desc;

    HasTenantEnum(Boolean type, String desc) {
        this.type = type;
        this.desc = desc;
    }


    public static HasTenantEnum of(Boolean type) {
        return MixAllUtils.ok(type) ? HAS : NONE;
    }

    public static boolean noneTenant(HasTenantEnum tenantEnum) {
        return tenantEnum == null || tenantEnum == NONE;
    }

    public static boolean hasTenant(HasTenantEnum tenantEnum) {
        return tenantEnum != null && tenantEnum == HAS;
    }

    public Boolean getType() {
        return type;
    }

    @Override
    public String getCode() {
        return type.toString();
    }

    @Override
    public String getDesc() {
        return desc;
    }

    @Override
    public String toString() {
        return String.format("[%s,%s]", getCode(), getDesc());
    }

}